package com.tjetc.input;

import org.junit.jupiter.api.Test;

import java.io.BufferedReader;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.util.Objects;

public class _3BufferedReader {


    @Test
    public void testBufferedReader() throws IOException {
        BufferedReader bufferedReader =
                new BufferedReader(new FileReader("/Users/gaoyongxiang/百度网盘/IDEA-Java/202507-java-se/chapter16/file/hello.txt"));
//        int read = bufferedReader.read();
//        System.out.println((char) read);

//        int readData = 0;
//        while ((readData = bufferedReader.read()) != -1) {
//            System.out.println((char) readData);
//        }

        char[] chars = new char[64];
        int len = 0;
        while ((len = bufferedReader.read(chars)) != -1) {
            System.out.println(new String(chars, 0, len));
        }
    }


    @Test
    public void testBufferedReader1() throws IOException {
        BufferedReader bufferedReader =
                new BufferedReader(new FileReader("/Users/gaoyongxiang/百度网盘/IDEA-Java/202507-java-se/chapter16/file/hello.txt"));
        String line = "";
        while (Objects.nonNull(line = bufferedReader.readLine())) {
            System.out.println(line);
        }

    }

}
